package com.ak.controller;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import lombok.extern.slf4j.Slf4j;
import com.ak.utils.R;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 〈一句话功能简述〉<br>
 * 〈〉
 *
 * @author xk
 * @create 2023/11/29 10:41
 * @since 1.0.0
 */
@Slf4j
@RestController
@RefreshScope
@RequestMapping("/test")
public class TestController {

//    @Value("${gateway.route.config.data_id}")
//    private String test;
//    @Autowired
//    private GatewayConfigProperties gatewayConfigProperties;

    @GetMapping("/gateway")
    public R getTest(){
//        System.err.println(gatewayConfigProperties.getData_id());
//        System.err.println(gatewayConfigProperties.getGroup());
//        System.out.println(test);
        return R.ok();
    }

    @GetMapping("/getOrder")
    public R getOrder(){
        return R.ok();
    }

    public static void main(String[] args) {
        try {
            ConfigService configService = NacosFactory.createConfigService("39.105.40.174:8848");

            String dataId = "ak-gateway-dev.yml";
            String groupId = "dev";
            // 指定 DataID,GroupID,超时时间 从而指定nacos中的配置文件
            String config = configService.getConfig(dataId, groupId, 5000);
            System.err.println(config);

        } catch (NacosException e) {
            e.printStackTrace();
        }
    }

}
